/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.index.SearchParams;
/*    */ import com.zimbra.cs.index.SearchParams.ExpandResults;
/*    */ import com.zimbra.cs.index.SortBy;
/*    */ import com.zimbra.cs.mailbox.Conversation;
/*    */ import com.zimbra.cs.mailbox.MailServiceException;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.Message;
/*    */ import com.zimbra.cs.mailbox.OperationContext;
/*    */ import com.zimbra.cs.service.util.ItemId;
/*    */ import com.zimbra.cs.service.util.ItemIdFormatter;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetConv
/*    */   extends MailDocumentHandler
/*    */ {
/* 43 */   private static final String[] TARGET_CONV_PATH = { "c", "id" };
/*    */   
/*    */   protected String[] getProxiedIdPath(Element request) {
/* 46 */     return TARGET_CONV_PATH;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException {
/* 50 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 51 */     Mailbox mbox = getRequestedMailbox(zsc);
/* 52 */     OperationContext octxt = getOperationContext(zsc, context);
/* 53 */     ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
/*    */     
/* 55 */     Element econv = request.getElement("c");
/* 56 */     ItemId iid = new ItemId(econv.getAttribute("id"), zsc);
/*    */     
/* 58 */     SearchParams params = new SearchParams();
/* 59 */     params.setInlineRule(SearchParams.ExpandResults.valueOf(econv.getAttribute("fetch", null), zsc));
/* 60 */     if (params.getInlineRule() != SearchParams.ExpandResults.NONE) {
/* 61 */       params.setWantHtml(econv.getAttributeBool("html", false));
/* 62 */       params.setMaxInlinedLength((int)econv.getAttributeLong("max", -1L));
/* 63 */       params.setWantExpandGroupInfo(econv.getAttributeBool("needExp", false));
/* 64 */       for (Element eHdr : econv.listElements("header")) {
/* 65 */         params.addInlinedHeader(eHdr.getAttribute("n"));
/*    */       }
/*    */     }
/*    */     
/* 69 */     Conversation conv = mbox.getConversationById(octxt, iid.getId());
/*    */     
/* 71 */     if (conv == null) {
/* 72 */       throw MailServiceException.NO_SUCH_CONV(iid.getId());
/*    */     }
/* 74 */     List<Message> msgs = mbox.getMessagesByConversation(octxt, conv.getId(), SortBy.DATE_ASC, -1);
/* 75 */     if ((msgs.isEmpty()) && (zsc.isDelegatedRequest())) {
/* 76 */       throw ServiceException.PERM_DENIED("you do not have sufficient permissions");
/*    */     }
/* 78 */     Element response = zsc.createElement(MailConstants.GET_CONV_RESPONSE);
/* 79 */     ToXML.encodeConversation(response, ifmt, octxt, conv, msgs, params);
/* 80 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetConv.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */